package news.service;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import news.dao.CommentDao;
import news.dao.NewsTypeDao;
import news.model.Comment;
import news.model.News;
import news.model.NewsType;
import news.util.JWTUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class CommentService {
    @Autowired(required = false)
    CommentDao commentDao;
    //查询所有评论并分页
    public PageInfo<Comment> commentList(Comment comment) {
        // pageNum当前页面  pageSize每页大小
        PageHelper.startPage(comment.getPageNum(), comment.getPageSize());
        List<Comment> comments = commentDao.commentList(comment);
        PageInfo<Comment> pageInfo = new PageInfo<Comment>(comments);
        return pageInfo;
    }

    public void delete(Integer id) {
        commentDao.delete(id);
    }

    //修改评论状态
    public void changeS(Integer id, Integer status) {
        commentDao.changeS(id,status);
    }

}
